﻿using Newtonsoft.Json;
using ReadNovel.API.Domain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;

namespace ReadNovel.API.Response.Book
{
    [DataContract]
    public class BookDetailResponse : BaseResponse
    {
        [DataMember(Name = "author")]
        public String Author { get; set; }

        [DataMember(Name = "sortname")]
        public String Sortname { get; set; }

        [DataMember(Name = "wordtotal")]
        public String Wordtotal { get; set; }

        [DataMember(Name = "totalviews")]
        public String Totalviews { get; set; }

        [DataMember(Name = "finishflag")]
        [JsonConverter(typeof(ReadNovel.API.JsonConverters.BoolJsonConverter))]
        public bool Finishflag { get; set; }

        [DataMember(Name = "book_logo")]
        public String Book_logo { get; set; }

        [DataMember(Name = "title")]
        public String Title { get; set; }

        [DataMember(Name = "voters")]
        public String Voters { get; set; }

        private string description;
        [DataMember(Name = "description")]
        public String Description
        {
            get
            {
                if (description != null && description.Length > 45)
                    return description.Substring(0, 45)+"...";
                   
                return description;
            }
            set
            {
                description = value;
            }
        }

        [DataMember(Name = "textcount")]
        public String Textcount { get; set; }

        [DataMember(Name = "free_textcount")]
        public String Free_textcount { get; set; }

        [DataMember(Name = "first_vip_chapter_displayorder")]
        public String First_vip_chapter_displayorder { get; set; }

        [DataMember(Name = "first_chapter_id")]
        public String First_chapter_id { get; set; }

        [DataMember(Name = "first_chapter_is_vip")]
        public String First_chapter_is_vip { get; set; }

        [DataMember(Name = "lastUpdateInfo")]
        public Lastupdateinfo LastUpdateInfo { get; set; }

        [DataContract]
        public class Lastupdateinfo
        {
            [DataMember(Name = "textid")]
            public String Textid { get; set; }

            [DataMember(Name = "is_vip")]
            public String Is_vip { get; set; }

            [DataMember(Name = "order")]
            public String Order { get; set; }

            [DataMember(Name = "chapter_title")]
            public String Chapter_title { get; set; }

            [DataMember(Name = "update_time")]
            [JsonConverter(typeof(ReadNovel.API.JsonConverters.DateTimeJsonConverter))]
            public DateTime Update_time { get; set; }

        }
    }
}
